package cn.stazxr.deepseekchat.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Utils for context
 *
 * @author talentestors
 * @version 1.0
 * @since 2025.3.15
 **/
public final class ContextUtils {
	public static StringBuilder replaceAll(StringBuilder sb, String target, String replacement) {
		Pattern pattern = Pattern.compile(target);
		Matcher matcher = pattern.matcher(sb);
		int start = 0;
		while (matcher.find(start)) {
			sb.replace(matcher.start(), matcher.end(), replacement);
			start = matcher.start() + replacement.length();
		}
		return sb;
	}
}
